package cc.rengu.redp.bizimpl.csmc.controller;


import cc.rengu.redp.bizimpl.csmc.domain.ReconSceneInfo;
import cc.rengu.redp.bizimpl.csmc.domain.ReconSceneStat;
import cc.rengu.redp.bizimpl.csmc.service.IReconSceneInfoService;
import cc.rengu.redp.bizimpl.csmc.service.IReconSceneStatService;
import cc.rengu.redp.bizimpl.csmc.service.IReconSysStatService;
import cc.rengu.redp.bizimpl.csmc.vo.ReconSceneStatVO;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpSysParamService;
import cc.rengu.redp.common.annotation.Log;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.domain.RedpResponse;
import cc.rengu.redp.common.exception.RedpException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Map;

/**
 * 对账场景管理
 * @author System
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/admin/csmc/reconscene")
@Api(tags = "统一对账管理：对账场景管理")
public class ReconSceneInfoController extends BaseController {

    private long oprMenuId = 1;
    private String oprMenuName = "统一对账管理:对账场景管理";
    private long chkMenuId = 2;
    private String chkMenuName = "统一对账管理:对账场景审核";
    private String webNextUrl = "/admin/csmc/reconSceneInfo/edit";

    @Autowired
    private IReconSceneStatService reconSceneStatService;

    @Autowired
    private IReconSceneInfoService reconSceneInfoService;

    @Autowired
    private IUpmpSysParamService upmpSysParamService;

    @Autowired
    private IReconSysStatService reconSysStatService;


    /*
    *
    * 查询对账系统状态
    * */
    @GetMapping("/getReconSysStat")
    public RedpResponse getReconSysStat(HttpServletRequest httpServletRequest){
        return reconSysStatService.getReconSysStat(httpServletRequest);
    }


    /**
     * 查询分页列表
     *
     * @param queryRequest
     * @return
     */
    @GetMapping
//    @RequiresPermissions("reconscene:list")
    public Map<String, Object> getPageList(QueryRequest queryRequest, ReconSceneStat reconSceneStat) throws RedpException{
        return getDataTable(reconSceneStatService.findByPage(queryRequest,reconSceneStat));
    }

    /**
     * 查询 对账场景与关联系统的数据列表
     *
     * @param queryRequest
     * @return
     */
    @GetMapping("/sublist")
//    @RequiresPermissions(value={"reconscene:list","reconscene:add","reconscene:update"},logical = Logical.OR)
    public Map<String, Object> getSubPageList(QueryRequest queryRequest, String reconSceneId, String instId)throws RedpException {
        return reconSceneInfoService.findByPage(reconSceneId,instId);
    }

    /**
     * 新增 对账场景管理
     *
     * @param reconSceneStat
     * @return
     */
    @Log("对账场景管理新增")
    @PostMapping("/add")
//    @RequiresPermissions("reconscene:add")
    public void add(ReconSceneStatVO reconSceneStat)throws RedpException {
        reconSceneStatService.add(reconSceneStat);
    }

    /**
     * 修改 对账场景管理
     *
     * @param reconSceneStat
     * @return
     */
    @Log("对账场景管理修改")
    @PostMapping("/update")
//    @RequiresPermissions("reconscene:update")
    public void update( ReconSceneStatVO reconSceneStat) throws RedpException{
        reconSceneStatService.update(reconSceneStat);
    }

    /**
     * 停用/启用 对账场景管理
     * @param id
     * @param optFlag
     * @throws RedpException
     */
    @Log("对账场景管理状态变更")
    @PutMapping(value={"/changeStatus/{optFlag}/{id}"})
//    @RequiresPermissions(value={"reconscene:stop","reconscene:use","reconscene:cancel"},logical = Logical.OR)
    public void changeStatus(@NotBlank(message = "{required}") @PathVariable String optFlag, @NotBlank(message = "{required}") @PathVariable String id ) throws RedpException{
        reconSceneStatService.changeStatus(id,optFlag);
    }

    /**
     * 详情 对账场景管理
     *
     * @param reconScene
     * @return
     */
    @GetMapping("/detail")
    @RequiresPermissions("reconscene:detail")
    public void detail(@Valid ReconSceneInfo reconScene) {

    }
}
